home *** CD-ROM | disk | FTP | other *** search
- #include <FixMath.h>
- #include <Strings.h>
- #include <Traps.h>
- #include <fp.h>
- #undef NAN /* Conflict between SANE's NAN function and NAN macros in fp.h */
- #include <SANE.h>
-
- /* Glue for fp.h */
- void dec2str ( const decform *f, const decimal *d, char *s )
- {
- Dec2Str((DecForm *)f,(Decimal *)d,(StringPtr)s);
- p2cstr((unsigned char *)s);
- }
-
- void str2dec ( const char *s, short *ix, decimal *d, short *vp )
- {
- CStr2Dec((char *)s,ix,(Decimal *)d,(Boolean *)vp);
- }
-
- double_t dec2num ( const decimal *d )
- {
- extended80 xtd80;
- #if __MC68881__
- extended96 xtd;
- #endif
-
- Dec2Num((Decimal *)d,&xtd80);
- #if __MC68881__
- x80tox96(&xtd80, &xtd);
- return ((double_t)xtd);
- #else
- return ((double_t)xtd80);
- #endif
- }
-
- void num2dec ( const decform *f, double_t x, decimal *d )
- {
- #if __MC68881__
- extended80 xtd80;
- extended96 xtd96 = x;
- x96tox80(&xtd96, &xtd80);
- #else
- extended80 xtd80 = x;
- #endif
-
- Num2Dec((DecForm *)f, &xtd80, (Decimal *)d);
- }
-
- double_t log2 ( double_t x )
- {
- extended80 xtd80;
- #if __MC68881__
- extended96 xtd96 = x;
- x96tox80(&xtd96, &xtd80);
- #else
- xtd80 = x;
- #endif
-
- Log2( &xtd80 );
-
- #if __MC68881__
- x80tox96(&xtd80, &xtd96);
- return (xtd96);
- #else
- return (xtd80);
- #endif
- }
-
- #if __MC68881__
-
- // SANE 10byte doubles code ...
-
- static pascal extended80 __Frac2X(Fract x) = {_Frac2X};
- static pascal extended80 __Fix2X(Fixed x) = {_Fix2X};
- static pascal Fixed __X2Fix(extended80 x) = {_X2Fix};
- static pascal Fract __X2Frac(extended80 x) = {_X2Frac};
-
- // Externally callable code ...
-
- pascal double_t Frac2X(Fract x)
- {
- extended96 xtd96;
- extended80 xtd80 = __Frac2X(x);
-
- x80tox96(&xtd80, &xtd96);
- return xtd96;
- }
-
- pascal double_t Fix2X(Fixed x)
- {
- extended96 xtd96;
- extended80 xtd80 = __Fix2X(x);
-
- x80tox96(&xtd80, &xtd96);
- return xtd96;
- }
-
- pascal Fixed X2Fix(double_t xtd96)
- {
- extended80 xtd80;
-
- x96tox80(&xtd96, &xtd80);
- return (__X2Fix(xtd80));
- }
-
- pascal Fract X2Frac(double_t xtd96)
- {
- extended80 xtd80;
-
- x96tox80(&xtd96, &xtd80);
- return (__X2Frac(xtd80));
- }
-
- #endif
-